using System;

namespace ScenarioFramework.Modules.DM.Application
{
	/// <summary>
	/// Descrizione di riepilogo per Main.
	/// </summary>
	public class MainClass
	{
		[STAThread]
		static void Main(string[] args)
		{
			WAPI.Response wapiResponse = new WAPI.Response();
			WAPI.Session.InitSession (ref wapiResponse, "DocumentManager", 7);

			if ( wapiResponse.iCode > 0 ) 
			{
				System.Console.WriteLine ("Impossible to start Application.Err[ {1} ]",wapiResponse.sMsg);
				return;

			}
			DocumentManagerApplication dmApplication =new DocumentManagerApplication();
			dmApplication.InstanceHelper();

            ScenarioFramework.Applications.ApplicationInterface application = new ScenarioFramework.Applications.ApplicationInterface();

			#region register CallBack 
            ScenarioFramework.Applications.CallBack cb = new ScenarioFramework.Applications.CallBack(dmApplication.CreateDocument);
			application.AddCallBack( cb, "CreateDocument" );

            cb = new ScenarioFramework.Applications.CallBack(dmApplication.AttachFile);
			application.AddCallBack( cb, "AttachFile" );

#endregion

			//starting Application
			if ( args.Length < 1 )
			{
				application.StartUp("DocumentManager");
			}
			else
			{
				application.StartUp(args[0]);
			}
			
			WAPI.Session.EndSession(ref wapiResponse);
		}
	}
}
